package com.ht.miscorservice.demo.server.fallback;

import com.ht.miscorservice.demo.server.fegin.Test1FeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @Author: tyh
 * @Date: 2022-04-01
 * @Description: 服务降级处理
 */
@Slf4j
@Component
public class DemoTestFallbackFactory implements FallbackFactory<Test1FeignService> {
  @Override
  public Test1FeignService create(Throwable cause) {

    log.info("服务2调用失败：{}",cause.getMessage());
    return new Test1FeignService() {
      @Override
      public String demoList(String s) {
        return "服务2暴露接口失败："+cause.getMessage();
      }

      @Override
      public String getResultData(String name) {
        return "服务2接口失败："+cause.getMessage();
      }
    };
  }
}
